from flask import Blueprint,render_template,request
import pymysql

rg = Blueprint('rg',__name__)

conn = pymysql.connect(
    host='127.0.0.1',
    user='root',
    password='123456',
    db='orderingsystem',
    charset='utf8'
)

@rg.route('/register')
def register():
    return render_template('register.html')
# @rg.route('/getRegisterRequest')
# def getRegisterRequest():#注册管理
#     user = request.args.get('userName')
#     pwd = request.args.get('password')
#     rpwd = request.args.get("rpassword")#从页面获取输入的确认密码
#     if user == '' or pwd == '':
#         return '不能为空!'
#     cursor = conn.cursor()
#     sql = "select user_name from user where user_name='" + user + "' " #查询数据库中是否存在此用户
#     if(pwd==rpwd):#判断密码与确认密码是否相同
#         try:
#             cursor.execute(sql)
#             result = cursor.fetchall()
#             if len(result) > 1:  # 若存在，提示'该用户已存在，请换号注册'
#                 return '该用户已存在，请换号注册'
#             else:#插入数据到数据库中
#                 cursor.execute('INSERT INTO user(user_name,pwd) VALUES(%s,%s)', (user, pwd))
#                 conn.commit()
#                 return '注册成功'
#             conn.commit()
#         except:
#             # 如果发生错误则回滚
#             traceback.print_exc()
#             conn.rollback()
#     else:
#         return '两次密码输入不一致'